﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace APPLICATION.ErrorDict
{
    class ErrFinder    
    {
        public string GetErrMessage(string SourceName, string ErrorNumber, string ErrMsg)
        {
            XmlReader xmlreader1;                      
            xmlreader1 = XmlReader.Create("ErrorDict\\ErrorSource.xml");
            xmlreader1.MoveToContent();


            while ( xmlreader1.Read() )
                {
                if ( xmlreader1.NodeType == XmlNodeType.Element)
                    {
                    xmlreader1.MoveToAttribute("Source");
                    if ( xmlreader1.Value == SourceName)
                        {
                          while (xmlreader1.Read())
                          {
                              if (xmlreader1.HasAttributes)
                              {
                                   xmlreader1.MoveToAttribute("ID");
                                   if (xmlreader1.Value == ErrorNumber)
                                   {
                                       xmlreader1.Read();
                                       return xmlreader1.Value.ToString();
                                   }
                              }
                          }
                        }
                    }
                }
            return ErrMsg;
        }
    }
    
}
